package com.xqboss.apps.domain.nft;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * nft发行记录
 * </p>
 *
 * @author hqw11
 * @since 2022-12-08
 */
@Data
@Accessors(chain = true)
@ApiModel(value = "NftPublishLog对象", description = "nft发行记录")
public class NftPublishLog {

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @ApiModelProperty(value = "藏品id")
    @NotNull(message = "nftId不能为空", groups = Destroy.class)
    private Long nftId;

    @ApiModelProperty(value = "藏品编号-带前缀")
    private String nftNumber;

    @ApiModelProperty(value = "藏品编号")
    @TableField(exist = false)
    private String number;

    public String getNumber() {
        if (nftNumber == null) {
            return 0 + "";
        }
        return Integer.parseInt(nftNumber.substring(7)) + "";
    }

    @ApiModelProperty(value = "出库时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date stockAt;

    @ApiModelProperty(value = "出库方式 1 首发 2 空投 3 熔炼 4 合成 5 开箱 ")
    private Byte stockType;

    @ApiModelProperty(value = "出库单号")
    private String stockNumber;

    @ApiModelProperty(value = "当前持有者id")
    private Long holdUserId;

    @ApiModelProperty(value = "藏品状态 0 未出库 1 已收藏 2 售卖中 3 交易中 4 已合成 5 已销毁 6孵化中")
    private Byte nftStat;

    @ApiModelProperty(value = "获得来源Id")
    private String lastId;

    @ApiModelProperty(value = "获得方式 1 首发 2 空投 3 熔炼 4 合成 5 开箱 6 转卖 7 转增")
    private Byte gainType;

    @ApiModelProperty(value = "会员-nft关联id")
    private Long sysMemberNftId;

    @ApiModelProperty(value = "组件序列号")
    private String unitIds;

    @ApiModelProperty(value = "组件图")
    private String unitImgList;


    @ApiModelProperty(value = "操作人ID")
    private Long adminId;

    @ApiModelProperty(value = "操作人名称")
    private String adminName;

    @ApiModelProperty(value = "属性")
    @TableField(exist = false)
    private List<NftAttr> nftAttrs;

    @ApiModelProperty(value = "已产蛋数量")
    @TableField(exist = false)
    private Integer hasIncubateNum;

    public Integer getHasIncubateNum() {
        if (hasIncubateNum == null) {
            return 0;
        }
        return hasIncubateNum;
    }

    @ApiModelProperty(value = "待产蛋数量")
    @TableField(exist = false)
    private Integer incubateNum;

//    @Field(type = FieldType.Date, name = "create_time", format = DateFormat.custom, pattern = "yyyy-MM-dd'T'HH:mm:ss")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Column(insertable = false, updatable = false)
    protected Date createTime;

    public interface Destroy {
    }

    public interface CancelSell {
    }


}
